#pragma once

#include "Thread.h"

#include "IEndPoint.h"
#include "IContractChecker.h"
#include "RoomMessage.h"

namespace RoomFW {

//
// Class:	IActiveObject
//
// Description:	Abstract Active Object interface.
//
// Author:	Andrew Sage
//
struct IActiveObject : public virtual Thread
{
	//
	// Port priorities
	//
	enum PortPriority
	{
		PRI_LOW,
		PRI_NORMAL,
		PRI_HIGH,
		PRI_CRITICAL
	};
	typedef std::vector<PortPriority> PortPriorityArray;

	//
	// Method:	~IActiveObject
	//
	// Description:	Virtual destructor to ensure derived class destructors called.
	//
	virtual ~IActiveObject() {};

	//
	// Method:	getObjectName
	//
	// Description:	Get a globally unique name for this object.
	//
	// Parameters:	None.
	//
	// Return:	Globally unique name for this object.
	//
	virtual const char* getObjectName(void) const = 0;

	//
	// Method:	getPortName
	//
	// Description:	Get the name of a specified port index.
	//
	// Parameters:
	//
	//	portIndex - Port index to get name for.
	//
	// Return:	Name of specified port index.
	//
	virtual const char* getPortName(size_t portIndex) const = 0;

	//
	// Method:	getEndPoint
	//
	// Description:	Get a new endpoint for this object's incoming messages.
	//
	// Parameters:
	//
	//	portIndex -	Primary index of port to set endpoint for.  Returns replication index.
	//
	//	endPoint -	The endpoint.
	//
	// Return:	Endpoint.
	//
	virtual IEndPointSP getEndPoint(PortIndex::PrimaryIndex portIndex) = 0;

	//
	// Method:	setEndPoint
	//
	// Description:	Set an endpoint for this object's outgoing messages.
	//
	// Parameters:
	//
	//	portIndex -	Index of port to set endpoint for.
	//
	//	endPoint -	The endpoint.
	//
	// Return:	Success.  Fails if port index already has an endpoint.
	//
	virtual bool setEndPoint(PortIndex& portIndex, IEndPointSP endPoint) = 0;

	//
	// Method:	clearEndPoint
	//
	// Description:	Clear an endpoint for this object's outgoing messages.
	//
	// Parameters:
	//
	//	portIndex -	Index of port to clear endpoint for.
	//
	// Return:	Success.  Fails if port index already clear.
	//
	virtual bool clearEndPoint(const PortIndex& portIndex) = 0;

	//
	// Method:	getContractChecker
	//
	// Description:	Get the contract checker for a specific port
	//
	// Parameters:
	//
	//	portIndex -	Index of port to get contract checker for.
	//
	// Return:	Contract checker or null.
	//
	virtual IContractCheckerSPC getContractChecker(PortIndex portIndex) const = 0;

	//
	// Method:	put
	//
	// Description:	Put a message on this object's queue.
	//
	// Parameters:
	//
	//	message -	Message to put.
	//
	// Return:	None.
	//
	virtual void put(RoomMessageSP message) = 0;

	//
	// Public interface so tests can get message info.  Impl here for Container::InnerWall.
	//
	virtual size_t timerPortIndex() const {return 0;}

};
typedef ::boost::shared_ptr<IActiveObject> IActiveObjectSP;

}
